<template>
  <div class="art-full-height" style="margin-top: 10px">
    <BasicCard class="art-table-card">
      <BasicVxeTable v-bind="gridOptions"> </BasicVxeTable>
    </BasicCard>
  </div>
</template>

<script setup lang="ts">
  import { columns } from './data'
  import { splitTsIdToTime } from '@/utils'
  import { getJiTaiBanBao_xs } from '@/api/shuJuBaoBiao'

  const { t } = useI18n()

  const gridOptions = reactive<BasicGridProps>({
    extraConfig: {
      isCustom: false,
      isExport: true,
      isFilterAndSort: true
    }, // 拓展的配置
    id: `shujubaobiao-jitaibaobiao`, // id用于缓存,务必配置
    height: '100%',
    loading: true,
    columns,
    toolbarConfig: {}, // 工具栏
    exportConfig: {
      filename: t('export.报表')
    }
  })

  const getList = () => {
    getJiTaiBanBao_xs({
      TsIdStart: 25072102,
      TsIdEnd: 25072102
    })
      .then((res: any) => {
        gridOptions.loading = false
        gridOptions.data = res.byTsidMachineDetail.map((value) => {
          return {
            ...value,
            tsid: splitTsIdToTime(value.tsid) + value.shiftName,
            machineDocumentId: value.machineDocumentId,
            yarnCount:
              value.yarnCount == null ? value.yarnCount : Math.round(value.yarnCount * 1) / 1,
            speedAvg1:
              value.speedAvg1 == null ? value.speedAvg1 : Math.round(value.speedAvg1 * 1) / 1,
            yarnLength:
              value.yarnLength == null ? value.yarnLength : Math.round(value.yarnLength * 1) / 1,
            dofferTimeAvg:
              value.dofferTimeAvg == null
                ? value.dofferTimeAvg
                : Math.round((value.dofferTimeAvg / 60) * 100) / 100,
            jointTimeAvg:
              value.jointTimeAvg == null
                ? value.jointTimeAvg
                : Math.round((value.jointTimeAvg / 60) * 100) / 100
          }
        })
      })
      .catch(() => {
        gridOptions.loading = false
      })
  }

  onMounted(() => {
    getList()
  })
</script>
